package com.interceptors;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.LoanApplication;

@Configuration
@ComponentScan(basePackageClasses = LoanApplication.class, useDefaultFilters = true)
public class WebInterceptors implements WebMvcConfigurer {

	@Bean
	public LoginInterceptors appIdInterceptors() {
		return new LoginInterceptors();
	}
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(appIdInterceptors())
				.addPathPatterns("/**")
				.excludePathPatterns("/feign/*")
				.excludePathPatterns("/wx/login/**")
				.excludePathPatterns("/login")
				.excludePathPatterns("/personLogin")
				.excludePathPatterns("/img/**")
				.excludePathPatterns("/apidoc/**")
				.excludePathPatterns("/css/**")
				.excludePathPatterns("/js/**");
	}

	@Override
	public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
		configurer.enable();
	}

}
